/*
 * luatest.cpp
 * This file is part of OpenAnimator
 *
 * Copyright (C) 2008 - Abhinav Lele
 *
 * OpenAnimator is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 3 of the License, or
 * (at your option) any later version.
 *
 * OpenAnimator is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with OpenAnimator; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, 
 * Boston, MA  02110-1301  USA
 */
 
 

#include "luatest.h"

TEST_FIXTURE(LuaTestFixture,DummyTest) {
	cout << "\nStarting LuaEnvironment Tests\nDummy Test\n";
}

TEST_FIXTURE(LuaTestFixture,BasicTest) {
	cout << "Basic Test\n";
	cout << "LuaVersion:" << myEnv.lang_ver << "\n";
}

TEST_FIXTURE(LuaTestFixture,LoadUnloadLibTest) {
	cout << "Load/Unload Library Test\n";
	if(myEnv.reload_env() != 1) CHECK(false); cout << "ALL_BASE Loading ";
	if(myEnv.load_library(LUALIB_ALLBASE) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "BASE Loading ";
	if(myEnv.load_library(LUALIB_BASE) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "TABLE Loading ";
	if(myEnv.load_library(LUALIB_TABLE) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "MATH Loading ";
	if(myEnv.load_library(LUALIB_MATH) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "STRING Loading ";
	if(myEnv.load_library(LUALIB_STRING) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "IO Loading ";
	if(myEnv.load_library(LUALIB_IO) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "DEBUG Loading ";
	if(myEnv.load_library(LUALIB_DEBUG) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "NET Loading ";
	if(myEnv.load_library(LUALIB_ALLBASE) != 1) CHECK(false);
	if(myEnv.load_library(LUALIB_NET) != 1) CHECK(false); cout << "Unloading\n";

	if(myEnv.reload_env() != 1) CHECK(false); cout << "XML Loading ";
	if(myEnv.load_library(LUALIB_ALLBASE) != 1) CHECK(false);
	if(myEnv.load_library(LUALIB_XML) != 1) CHECK(false); cout << "Unloading\n";

	if(myEnv.reload_env() != 1) CHECK(false); cout << "OPENGL Loading ";
	if(myEnv.load_library(LUALIB_ALLBASE) != 1) CHECK(false);
	if(myEnv.load_library(LUALIB_OPENGL) != 1) CHECK(false); cout << "Unloading\n";
	
	if(myEnv.reload_env() != 1) CHECK(false); cout << "FONT Loading ";
	if(myEnv.load_library(LUALIB_ALLBASE) != 1) CHECK(false);
	if(myEnv.load_library(LUALIB_FONT) != 1) CHECK(false); cout << "Unloading\n";


	if(myEnv.reload_env() != 1) CHECK(false);
/*	 if(myEnv.load_library(LUALIB_TABLE) != -1) CHECK(false);
	myEnv.reload_env(); if(myEnv.load_library(LUALIB_MATH) != -1) CHECK(false);
	myEnv.reload_env(); if(myEnv.load_library(LUALIB_STRING) != -1) CHECK(false);
	myEnv.reload_env(); if(myEnv.load_library(LUALIB_IO) != -1) CHECK(false);
	myEnv.reload_env(); if(myEnv.load_library(LUALIB_DEBUG) != -1) CHECK(false);
*/


}

TEST_FIXTURE(LuaTestFixture,LoadFileTest) {
	cout << "Load File Test\n";
	if(myEnv.reload_env() != 1) CHECK(false); 
	//Try to load a non existent file
	if(myEnv.load_file("/vvv") == 1) CHECK(false);
	if(myEnv.load_file("/tmp") == 1) CHECK(false);
}

/*
TEST_FIXTURE(LuaTestFixture,CallTest) {
	myEnv.call("gcinfo()");
}*/
